import {
  INCREMENTCOUNT,
  DECREMENTCOUNT
} from '../constant/countConst'

const init = {
  count :0
}

export default function countReducer(prestate=init,action){

  console.log('countReducers运行了');

  // console.log("prestate",prestate,"action",action);
  const {type,data} =  action
  // console.log(type,data);
  
  switch(type){

    case INCREMENTCOUNT:
      return {
        ...init, count : prestate.count +data
      };

      case DECREMENTCOUNT:
        return {
          ...init, count : prestate.count -data
        };

  }


   
  return prestate
  
}